Many programming languages support extending symbolic operators to support new types. From my experiences, unary operator definitions take one (1) parameter; binary operator definitions take two (2) parameters; and so on. ::do(SignatureEntry&, SignatureInfo, void) // Declaration void ::do(SignatureEntry& sigentry, SignatureInfo si, void) ::do(AccessRec&, SignatureInfo, void) // Declaration void ::do(AccessRec& ar, SignatureInfo si, void) ::do(AccessRec&, SignatureInfoSpecifier__, void) // Declaration void ::do(AccessRec& ar, SignatureInfoSpecifier__ sis, void)
string ::.(string p1, int p2, bool p3, string p4) {
return "" (upper(p1)) "" (p2+5) "" (p3) "" (lower(p4)) "";
}
SystemAdmin - Tue Jun 22 09:34:48 EDT 2010 |
Re: DXL Binary Operators Definitions :: with More Than Two Parameters? The . is a binary operator and therefore a declaration should look like this:
string ::.(string s, int i)
{
int j
string sReturn = ""
if ( i > 0 )
{
for j in 0:i do
{
sReturn = sReturn s
}
}
return(sReturn)
}
string s = "hello"
string result = s.4
print result
|
Re: DXL Binary Operators Definitions :: with More Than Two Parameters? a_vestlin - Tue Jun 22 11:08:35 EDT 2010 The . is a binary operator and therefore a declaration should look like this:
string ::.(string s, int i)
{
int j
string sReturn = ""
if ( i > 0 )
{
for j in 0:i do
{
sReturn = sReturn s
}
}
return(sReturn)
}
string s = "hello"
string result = s.4
print result
However, you call see from my example that DXL did allow me to "implement" it (to my surprise it compiled fine.) Forget about the operator symbol and whether it makes sense. More generally, I was wondering how one would call an extended operator that has more than two parameters. QUESTION: Given the compiled implementation, how is is called? The code I gave was a simple, silly example for illustration purposes of concept. Consideration of any real use depends on how neat (or ugly) the invocation (call to it) is. POSSIBILITIES: 1) Even though the code compiled, there may be no valid syntax to call it. 2) It is callable, but the syntax is illusive and undocumented. |
Re: DXL Binary Operators Definitions :: with More Than Two Parameters? SystemAdmin - Tue Jun 22 11:32:03 EDT 2010
uhm ... if you compile a function like this ::.(int a, int b, int c) you can always call it using ::.(1,2,3). No magic syntax there i guess ...
Skip ::..(int a, Skip b) {
int count = -1
find(b, -1, count)
put(b, -1, ++count,true)
put(b, count, a)
return b
}
Skip ::..(int a, int b) {
Skip x = create()
put (x, -1, 1)
put (x, 0, b )
put (x, 1, a )
return x
}
void create (Skip x) {
int val
for val in x do {
if ((key x) int != -1) {
print "Processing value: " val "\n"
}
}
}
create 3 4 5 6 7
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: DXL Binary Operators Definitions :: with More Than Two Parameters? void ::do(SignatureEntry&, SignatureInfo, void) is required whwn writing: SignatureEntry se for se in (SignatureInfo si) do { .... } So the operator declaration using three arguments is just another interesting DXl syntax ... |
Re: DXL Binary Operators Definitions :: with More Than Two Parameters? SystemAdmin - Sun Feb 24 12:08:18 EST 2013 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |